<?php defined('DML') or die("Access locked");

$conf = new Config;

define('CSS', BASEHREF.'tamplates/'.$conf->tamplate.'/');

$tpl['main'] = PATH.DS.'tamplates'.DS.$conf->tamplate.DS.'index.tpl';
$tpl['note'] = PATH.DS.'tamplates'.DS.$conf->tamplate.DS.'note.tpl';
$tpl['archiv'] = PATH.DS.'tamplates'.DS.$conf->tamplate.DS.'archiv.tpl';

$data['title'] = $conf->title;

$mysql = new MySQL($conf->dbhost, $conf->dbuser, $conf->dbpassw, $conf->db, $tpl);

define("PERPAGE", $conf->maxnote);
define("URL", basename($_SERVER["PHP_SELF"])."?");
if(isset($_GET['page'])){
   $page = $_GET['page'];
}else{
   $page = 1;
}
$mysql->Select($page, PERPAGE);
$data['content'] = $mysql->ParseTemplate('note');
$mysql->ArchiveNotes();
$data['archiv'] = $mysql->ParseTemplate('archiv');

$totalrecords = $mysql->totalrecords;
$numpage = ceil($totalrecords/PERPAGE);
if($numpage > 1){
   $nav = new PageNavigation($page, $totalrecords, URL, PERPAGE);
   $data['pagenav'] = $nav->getNavigator();
}

$html = ParseTamplatePath($data, $tpl['main']);
echo $html;
echo "Запросов к базе ".$mysql->total_queries."<br />";

?>
